# 使用Git绝对路径
$gitPath = "C:\Program Files\Git\bin\git.exe"
$projectPath = "d:\MCP"

# 切换到项目目录
Set-Location -Path $projectPath
Write-Host "Changed directory to $projectPath"

# 查看Git状态
& $gitPath status
Write-Host "Git status checked."

# 查看提交历史
& $gitPath log
Write-Host "Commit history checked."

# 推送代码到远程仓库
try {
    Write-Host "Pushing code to Gitee..."
    & $gitPath push -u origin master
    if ($LASTEXITCODE -eq 0) {
        Write-Host "Code pushed successfully!"
    } else {
        Write-Host "Failed to push code. Error code: $LASTEXITCODE"
        Write-Host "Please check network connection and Gitee credentials."
    }
} catch {
    Write-Host "An error occurred while pushing code: $_"
}

pause